package org.tlipoca.smsteamuserachievement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.genntii.smdomain.entity.SteamUserAchievement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.tlipoca.smsteamuserachievement.mapper.SteamUserAchievementMapper;
import org.tlipoca.smsteamuserachievement.service.SteamUserAchievementService;

import java.util.ArrayList;

@Service
public class SteamUserAchievementServiceImpl extends ServiceImpl<SteamUserAchievementMapper, SteamUserAchievement> implements SteamUserAchievementService {

    @Autowired
    private SteamUserAchievementMapper steamUserAchievementMapper;

    @Override
    public void updateSteamUserAchievementService(Long steamid) {

    }

    @Override
    public ArrayList<SteamUserAchievement> getSteamUserAchievementService(Long steamid) {

        // 判断数据库是否存在用户成就信息
        if (!steamUserAchievementMapper.exists(new QueryWrapper<SteamUserAchievement>().eq("steamid", steamid))) {
            // 不存在 尝试请求SteamApi获取数据

        }

        // 存在 返回Mysql内用户成就信息

        return null;
    }

    // 获取SteamApi用户成就数据
    private ArrayList<SteamUserAchievement> getSteamUserAchievementFromSteamApi() {
        // OpenFeign客户端发送请求获取用户库存信息

        // 遍历用户库存信息 尝试请求SteamApi查询用户成就信息

        return null;
    }
}
